import { Button } from 'antd';
import { useHistory } from 'umi';
// import { history, useModel } from 'umi';
import styles from './index.less';

const Login: React.FC = () => {
  const history = useHistory();
  // const { initialState, setInitialState } = useModel('@@initialState');

  // const handleSubmit = async (values) => {
  //   try {
  //     // 登录
  //     const msg = await login({ ...values, type });

  //     if (msg.status === 'ok') {
  //       const defaultLoginSuccessMessage = '登录成功！';
  //       message.success(defaultLoginSuccessMessage);
  //       await fetchUserInfo();
  //       /** 此方法会跳转到 redirect 参数所在的位置 */

  //       if (!history) return;
  //       const { query } = history.location;
  //       const { redirect } = query as {
  //         redirect: string;
  //       };
  //       history.push(redirect || '/');
  //       return;
  //     }

  //     console.log(msg); // 如果失败去设置用户错误信息

  //     setUserLoginState(msg);
  //   } catch (error) {
  //     const defaultLoginFailureMessage = '登录失败，请重试！';
  //     message.error(defaultLoginFailureMessage);
  //   }
  // };

  return (
    <div className={styles.container}>
      <div>
        <Button
          type="primary"
          onClick={() => {
            history.replace('/');
          }}
        >
          登录🤪
        </Button>
      </div>
    </div>
  );
};

export default Login;
